package cn.itsource.blog.service.impl;

import cn.itsource.blog.domain.Comment;
import cn.itsource.blog.repository.CommentRepository;
import cn.itsource.blog.service.ICommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class CommentServiceImpl implements ICommentService {

    @Autowired
    private CommentRepository repository;

    @Override
    public void add(Comment comment) {
        repository.save(comment);
    }


    @Override
    public void update(Comment comment) {
        repository.save(comment);
    }

    @Override
    public void delete(String id) { // MongoDB的主键id是string类型的
        repository.deleteById(id);
    }

    @Override
    public List<Comment> findByArticleId(Long articleId) {
        return repository.findByArticleId(articleId);
    }


}
